package cn.edu.lsu.integratedsurvey.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.edu.lsu.integratedsurvey.bean.LoginRecords;
import cn.edu.lsu.integratedsurvey.service.LoginRecordsService;
import cn.edu.lsu.integratedsurvey.mapper.LoginRecordsMapper;
import org.springframework.stereotype.Service;

/**
 *
 * @description 针对表【login_records(jwt记录表)】的数据库操作Service实现
 * @Date 2024-05-02 13:20:51
 * @author Jasmine-drs
 */
@Service
public class LoginRecordsServiceImpl extends ServiceImpl<LoginRecordsMapper, LoginRecords> implements LoginRecordsService{

	private final LoginRecordsMapper loginRecordsMapper;

	public LoginRecordsServiceImpl(LoginRecordsMapper loginRecordsMapper) {
		this.loginRecordsMapper = loginRecordsMapper;
	}

	@Override
	public void logout(String token) {
//		删除登录记录
		LambdaQueryWrapper<LoginRecords> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(LoginRecords::getJwt, token);
		loginRecordsMapper.delete(wrapper);
	}
}




